package com.atguigu.day08.bean.test02;

public class TestCircle {
    public static void main(String[] args) {
        Circle c1 = new Circle();
        c1.setR(2);
        System.out.println("c1的半径是" + c1.getR());
        System.out.println("c1的面积是");
        c1.showArea();
        System.out.println("c1的周长是");
        c1.showPerimeter();
        Circle c2 = new Circle(3);
        System.out.println("c2的半径是" + c2.getR());
        System.out.println("c2的面积是");
        c2.showArea();
        System.out.println("c2的周长是");
        c2.showPerimeter();
    }
}

class Circle {
    private double r;

    public Circle() {
    }

    public Circle(double r) {
        this.r = r;
    }

    public double getR() {
        return r;
    }

    public void setR(double r) {
        this.r = r;
    }

    public void showArea() {
        System.out.println(Math.PI * r * r);
    }

    public void showPerimeter() {
        System.out.println(Math.PI * 2 * r);
    }
}
